package com.lsa.letcode.the98.validateBst;

import static org.junit.Assert.*;

import java.io.IOException;

import org.junit.Test;

import com.lsa.letcode.common.LetCodeTestBase;
import com.lsa.letcode.common.TreeNode;
import com.lsa.letcode.common.TreeUtils;

public class ValidateBstTest extends LetCodeTestBase{
	@Test
	public void test() throws Exception {
		test("bstFalse1.tgf", false);
		test("bstFalse2.tgf", false);
		test("bstFalse3.tgf", false);
		test("bstTrue1.tgf", true);
		test("bstTrue2.tgf", true);
	}

	private void test(String resName, boolean isBst) throws IOException {
		TreeNode n = TreeUtils.fromTgf(this.getClass(), resName);
		Solution s = new Solution();
		assertTrue(isBst == s.isValidBST(n));
	}
}